<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        li {
            list-style: none;
        }
        
        .box {
            margin: 60px auto;
            width: 300px;
            border: 2px solid #cccccc;
            position: relative;
        }
        
        img {
            width: 16px;
            vertical-align: middle;
        }
        
        li {
            position: relative;
            border-top: 1px solid #cccccc;
            padding: 15px 20px;
            cursor: pointer;
        }
        
        .img {
            position: absolute;
            right: 20px;
            color: #999999;
        }
        
        .span1 {
            color: #999999;
            font-size: 12px;
        }
        
        .p1 {
            margin-bottom: 5px;
        }
        
        .p2 {
            border-top: 1px solid #cccccc;
            padding-top: 10px;
            width: 260px;
            text-align: center;
            cursor: pointer;
        }
        
        p {
            padding: 10px 20px;
        }
        
        .two {
            background-color: #cccccc;
            position: relative;
            display: none;
        }
        
        .two_span1,
        .two_span2 {
            font-size: 12px;
            color: #999999;
        }
        
        .span_but {
            position: absolute;
            right: 0;
            top: 15px;
            padding: 15px;
            border-left: 1px solid #999999;
        }
        
        .li_two {
            border-bottom: 1px solid #66666a;
        }
        
        .box2 {
            width: 80px;
            height: 60px;
            text-align: center;
            line-height: 60px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: cornflowerblue;
            display: none;
        }
    </style>
</head>

<body>
    <div class="box">
        <p class="p1">区块标题</p>
        <ul>
            <li class="li_one">
                一级标题 <span class="span1">一级标题说明</span> <span class="img"><img src="img/向下.png" alt=""></span>
                <ul class="two">
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <p class="two_p2">查看剩余标题 <img src="img/向下.png" alt=""></p>
                </ul>
            </li>
            <li class="li_one">
                一级标题 <span class="span1">一级标题说明</span> <span class="img"><img src="img/向下.png" alt=""></span>
                <ul class="two">
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <p class="two_p2">查看剩余标题 <img src="img/向下.png" alt=""></p>
                </ul>
            </li>
            <li class="li_one">
                一级标题 <span class="span1">一级标题说明</span> <span class="img"><img src="img/向下.png" alt=""></span>
                <ul class="two">
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <p class="two_p2">查看剩余标题 <img src="img/向下.png" alt=""></p>
                </ul>
            </li>
            <li class="li_one">
                一级标题 <span class="span1">一级标题说明</span> <span class="img"><img src="img/向下.png" alt=""></span>
                <ul class="two">
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <li class="li_two">
                        二级标题<br>
                        <span class="two_span1">二级标题说明</span><br>
                        <span class="two_span2">标签</span>
                        <span class="span_but"><button class="but">弹窗</button></span>
                    </li>
                    <p class="two_p2">查看剩余标题 <img src="img/向下.png" alt=""></p>
                </ul>
            </li>
        </ul>
        <p class="p2">查看剩余标题 <img src="img/向下.png" alt=""></p>
        <div class="box2">
            <span class="a"></span>---<span class="b"></span>
        </div>
    </div>
    <script>
        let p2 = document.querySelectorAll('.p2')[0];
        let two_p2 = document.querySelectorAll('.two_p2');
        let liList = document.querySelectorAll('.li_one');
        let but = document.querySelectorAll('.but');
        let a = document.querySelectorAll('.a')[0];
        let b = document.querySelectorAll('.b')[0];
        let show = false;
        let box2 = document.querySelectorAll('.box2')[0];
        // 一级标题
        for (let i = 0; i < liList.length; i++) {
            if (i > 1) {
                liList[i].style.display = 'none'
            }
            liList[i].setAttribute('one', i)
            liList[i].onclick = function() {
                liList[i].querySelectorAll('ul')[0].style.display = 'block';
                let twoLi = this.querySelectorAll('li')
                for (let o = 0; o < twoLi.length; o++) {
                    twoLi[o].setAttribute('two', o);
                    if (show === false) {
                        if (o > 1) {
                            twoLi[o].style.display = 'none'
                        }
                    }

                }
            }
        }
        p2.onclick = function() {
            for (let i = 0; i < liList.length; i++) {
                if (i > 1) {
                    liList[i].style.display = 'block'
                }
            }
            p2.style.display = 'none'
        }

        // 二级标题
        for (let o = 0; o < two_p2.length; o++) {

            two_p2[o].onclick = function() {
                show = true
                for (let i = 0; i < two_p2[o].parentNode.querySelectorAll('li').length; i++) {
                    two_p2[o].parentNode.querySelectorAll('li')[i].style.display = 'block';
                    two_p2[o].style.display = 'none';
                }
            }
        }

        // 弹窗
        for (let i = 0; i < but.length; i++) {
            but[i].onclick = function() {
                let twoUl = this.parentNode.parentNode.parentNode
                let num1 = twoUl.parentNode.getAttribute('one');
                let num2 = this.parentNode.parentNode.getAttribute('two');
                a.innerHTML = num1;
                b.innerHTML = num2;
                box2.style.display = 'block'
            }
        }
    </script>
</body>

</html>